package com.mychat.controller;

import com.mychat.annotation.GlobalInterceptor;
import com.mychat.entity.po.UserInfoBeauty;
import com.mychat.entity.query.UserInfoBeautyQuery;
import com.mychat.entity.query.UserInfoQuery;
import com.mychat.entity.vo.PaginationResultVO;
import com.mychat.entity.vo.ResponseVO;
import com.mychat.exception.BusinessException;
import com.mychat.service.UserInfoBeautyService;
import com.mychat.service.UserInfoService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;

@RestController
@RequestMapping("/admin")
public class AdminUserInfoBeautyController extends ABaseController {

    @Resource
    private UserInfoBeautyService userInfoBeautyService;

    @RequestMapping("/loadBeautyAccountLst")
    @GlobalInterceptor(checkAdmin = true)
    public ResponseVO loadBeautyAccountLst(UserInfoBeautyQuery userInfoBeautyQuery) {
        userInfoBeautyQuery.setOrderBy("id desc");
        PaginationResultVO resultVO = userInfoBeautyService.findListByPage(userInfoBeautyQuery);
        return getSuccessResponseVO(resultVO);
    }

    @RequestMapping("/saveBeautyAccount")
    @GlobalInterceptor(checkAdmin = true)
    public ResponseVO saveBeautyAccount(UserInfoBeauty userInfoBeauty) throws BusinessException {
        userInfoBeautyService.saveAccount(userInfoBeauty);
        return getSuccessResponseVO(null);
    }

    @RequestMapping("/delBeautyAccount")
    @GlobalInterceptor(checkAdmin = true)
    public ResponseVO delBeautyAccount(@NotNull Integer id) {
        userInfoBeautyService.deleteUserInfoBeautyByUserId(id);
        return getSuccessResponseVO(null);
    }


}
